<?php

if ( !file_exists( dirname(__FILE__) . '/tr-config.php') ) {
	if ( strstr( $_SERVER['PHP_SELF'], 'admin') ) $path = '';
	else $path = '';

  require_once( dirname(__FILE__) . '/tr-includes/functions.php');
  tr_die("There doesn't seem to be a <code>tr-config.php</code> file. I need this before we can get started. Need more help? <a href='http://www.ericfish.com/hologon'>We got it</a>. You can <a href='{$path}setup-config.php'>create a <code>tr-config.php</code> file through a web interface</a>, but this doesn't work for all server setups. The safest way is to manually create the file.", "Hologon &rsaquo; Error");
}


require_once( dirname(__FILE__) . '/tr-config.php');

require_once(ABSPATH.'tr-settings.php');

// Template redirection
if ( defined('TR_USE_THEMES') && constant('TR_USE_THEMES') ) {
	if (is_login()) {
		include(TEMPLATEPATH . '/login.php');
	}
	elseif (is_register()) {
		include(TEMPLATEPATH . '/register.php');
	}
	elseif (is_services()) {
		include(TEMPLATEPATH . '/services.php');
	}
	elseif (is_about()) {
		include(TEMPLATEPATH . '/about.php');
	}
	elseif (is_contact()) {
		include(TEMPLATEPATH . '/contact.php');
	}
	elseif (is_submit()) {
		include(TEMPLATEPATH . '/submit.php');
	}
	elseif (is_queue()) {
		include(TEMPLATEPATH . '/queue.php');
	}
	elseif (is_editpost()) {
		include(TEMPLATEPATH . '/editpost.php');
	}
	elseif (is_page()&&!is_editpost()) {
		include(TEMPLATEPATH . '/page.php');
	}
	elseif (is_user_profile()) {
		include(TEMPLATEPATH . '/userprofile.php');
	}
	elseif (is_search()) {
		include(TEMPLATEPATH . '/search.php');
	}
	elseif (is_feed()) {
		include(TEMPLATEPATH . '/feed.php');
	}
	elseif (is_tagcloud()) {
		include(TEMPLATEPATH . '/tagcloud.php');
	}
	elseif (is_top10()) {
		include(TEMPLATEPATH . '/top10.php');
	}
	elseif (is_userlist()) {
		include(TEMPLATEPATH . '/userlist.php');
	}
	elseif (is_post()) {
		include(TEMPLATEPATH . '/post.php');
	}
	elseif (is_user_home()||is_user_submitted()||is_user_commented()) {
		include(TEMPLATEPATH . '/user.php');
	}
	elseif (is_tagadmin()) {
		include(TEMPLATEPATH . '/tagadmin.php');
	}
	elseif (is_optionadmin()) {
		include(TEMPLATEPATH . '/optionadmin.php');
	}
	elseif (is_admin()) {
		include(TEMPLATEPATH . '/admin.php');
	}
	elseif( file_exists(TEMPLATEPATH . "/index.php") ) {
		include(TEMPLATEPATH . '/index.php');
	}
}

?>
